package com.iflytek.day27;

import java.io.*;

public class _08_ConversionStreamDemo {
  public static void main(String[] args) throws IOException {
    // OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("src\\com\\iflytek\\day27\\osw.txt"));
    OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("src\\com\\iflytek\\day27\\osw.txt"), "GBK");
    osw.write("中国");
    osw.close();

    // InputStreamReader isr = new InputStreamReader(new FileInputStream("src\\com\\iflytek\\day27\\osw.txt"));
    InputStreamReader isr = new InputStreamReader(new FileInputStream("src\\com\\iflytek\\day27\\osw.txt"), "GBK");
    // 一次读取一个字符数据
    int ch;
    while ((ch = isr.read()) != -1) {
      System.out.print((char) ch);
    }
    isr.close();
  }
}
